package com.anyou.mall.pla.service.impl;

import java.util.List;

import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.utils.DateUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.anyou.mall.pla.mapper.PlaPartsBrandMapper;
import com.anyou.mall.pla.domain.PlaPartsBrand;
import com.anyou.mall.pla.service.IPlaPartsBrandService;

/**
 * 配件品牌Service业务层处理
 *
 * @author ylj
 * @date 2022-03-18
 */
@Service
public class PlaPartsBrandServiceImpl extends ServiceImpl<PlaPartsBrandMapper, PlaPartsBrand> implements IPlaPartsBrandService
{
    @Autowired
    private PlaPartsBrandMapper plaPartsBrandMapper;

    /**
     * 查询配件品牌
     *
     * @param partsBrandId 配件品牌主键
     * @return 配件品牌
     */
    @Override
    public PlaPartsBrand selectPlaPartsBrandByPartsBrandId(Long partsBrandId)
    {
        return plaPartsBrandMapper.selectPlaPartsBrandByPartsBrandId(partsBrandId);
    }

    /**
     * 查询配件品牌列表
     *
     * @param plaPartsBrand 配件品牌
     * @return 配件品牌
     */
    @Override
    public List<PlaPartsBrand> selectPlaPartsBrandList(PlaPartsBrand plaPartsBrand)
    {
        return plaPartsBrandMapper.selectPlaPartsBrandList(plaPartsBrand);
    }

    /**
     * 新增配件品牌
     *
     * @param plaPartsBrand 配件品牌
     * @return 结果
     */
    @Override
    public int insertPlaPartsBrand(PlaPartsBrand plaPartsBrand)
    {
        plaPartsBrand.setCreateTime(DateUtils.getNowDate());
        return plaPartsBrandMapper.insertPlaPartsBrand(plaPartsBrand);
    }

    /**
     * 修改配件品牌
     *
     * @param plaPartsBrand 配件品牌
     * @return 结果
     */
    @Override
    public int updatePlaPartsBrand(PlaPartsBrand plaPartsBrand)
    {
        plaPartsBrand.setUpdateTime(DateUtils.getNowDate());
        return plaPartsBrandMapper.updatePlaPartsBrand(plaPartsBrand);
    }

    /**
     * 批量删除配件品牌
     *
     * @param partsBrandIds 需要删除的配件品牌主键
     * @return 结果
     */
    @Override
    public int deletePlaPartsBrandByPartsBrandIds(Long[] partsBrandIds)
    {
        return plaPartsBrandMapper.deletePlaPartsBrandByPartsBrandIds(partsBrandIds);
    }

    /**
     * 删除配件品牌信息
     *
     * @param partsBrandId 配件品牌主键
     * @return 结果
     */
    @Override
    public int deletePlaPartsBrandByPartsBrandId(Long partsBrandId)
    {
        return plaPartsBrandMapper.deletePlaPartsBrandByPartsBrandId(partsBrandId);
    }

    @Override
    public ApiResult<List<PlaPartsBrand>> getAllList() {
        List<PlaPartsBrand> list = plaPartsBrandMapper.selectList(new LambdaQueryWrapper<PlaPartsBrand>().eq(PlaPartsBrand::getDelFlag, "0"));
        return ApiResult.success(list);
    }
}
